<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head lang="en">
    <meta charset="UTF-8">
    <title>精益书城首页</title>
    <link type="text/css" rel="stylesheet" href="dist/css/bootstrap.min.css" th:href="@{/dist/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" href="css/index.css" th:href="@{/css/index.css}">
    <link rel="stylesheet" type="text/css" href="css/animate.css" th:href="@{/css/animate.css}"/>
</head>

<body>
<!--导航部分  begin-->
<div th:replace="common/header::header"></div>
<!--导航部分 end-->

<!--最顶端轮播图片 begin-->
<div th:replace="common/carousel::carousel"></div>
<!--最顶端轮播图片 end-->

<!--图书内容部分 begin-->
<div class="container">
    <!--精选图书 begin-->
    <div>
        <div class="text-primary"><img th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">精选图书</a>
        </div>
        <!--加载数据-->
        <div id="selected"></div>
    </div>
    <!--精选图书 end-->

    <!--推荐图书 begin-->
    <div>
        <div class="text-primary"><img th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">推荐图书</a>
        </div>
        <!--加载数据-->
        <div id="recommend"></div>
    </div>
    <!--推荐图书end..-->

    <!--特价图书 begin-->
    <div>
        <div class="text-primary"><img th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">特价图书</a>
        </div>
        <!--加载数据-->
        <div id="bargain"></div>
    </div>
    <!--特价图书 end-->
    <hr>
    <!--首页底部信息 begin-->
    <div th:replace="common/footer::footer"></div>
</div>
<!--首页底部信息end-->
<!--图书内容部分end-->

<!--登录注册模态框-->
<div th:replace="common/login_register::login_register"></div>

<script th:src="@{/dist/js/jquery.min.js}"></script>
<script th:src="@{/js/carousel.js}" type="text/javascript" charset="utf-8"></script>
<script th:src="@{/dist/js/bootstrap.min.js}"></script>
<script th:src="@{/js/wow.js}"></script>
<script th:src="@{/js/login_register.js}"></script>
<script th:inline="javascript">
    //获取应用路径
    var contextPath = [[${#request.getContextPath()}]];
</script>
<script type="text/javascript">
    if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
        new WOW().init();
    }
    ;

    $(function () {
        $("#selected").load(contextPath + "/book/getBookData", bindQuery(1, 1));
        $("#recommend").load(contextPath + "/book/getBookData", bindQuery(1, 2));
        $("#bargain").load(contextPath + "/book/getBookData", bindQuery(1, 3));
    })

    //加载其他页面的数据
    function loadData(page, category) {
        var node = "";
        if (category == "1") {
            node = "selected";
        } else if (category == "2") {
            node = "recommend";
        } else {
            node = "bargain";
        }
        $("#" + node).load(contextPath + "/book/getBookData", bindQuery(page, category));
    }

    //包装查询参数
    function bindQuery(page, category) {
        var query = {};
        query.page = typeof page == "undefined" ? 1 : page;
        query.category = category
        return query;
    }



</script>
</body>

</html>